<link rel="stylesheet" type="text/css" href="__CDN__/static/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="__CDN__/static/css/login.css"/>
<div id="content-container-res">
    <div class="row  rowClass">
        <div style="position: absolute; top: 65px; left: 50px;">
            {if $site.b_logo}
            <img src="{$site.b_logo}" style="width: 150px" alt="Logo">
            {else}
            <img style="width: 150px"
                 src="https://img0.baidu.com/it/u=933220220,287299241&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500"
                 alt="Logo">
            {/if}
        </div>
<!--        <div class="closeCLass close-modal"> <i class="fa fa-close"></i></div>-->
        <div class="col-lg-6 d-flex align-items-center justify-content-center">
            <div class="login-main form-vertical  flexClass">
                <div class="flexClasstext">微信登录</div>
                <div class="flexClassImg">
                    <img style="width: 210px;height: 210px;border-radius: 30px;"
                         src="https://img0.baidu.com/it/u=582752653,3386538207&fm=253&fmt=auto&app=138&f=GIF?w=500&h=500"
                         alt="">
                </div>
                <div class="flexClasst">使用微信扫一扫登录</div>
            </div>
        </div>
    <div class="user-section  login-section col-lg-6">
        <div class="logon-tab">
            <div class="active">注册</div>
            <a  class="register" id="showLogin">去登录</a>
        </div>
        <div class="login-main">
            <form name="form1" id="register-form" class="form-vertical" method="POST" action="">
                <!--@IndexRegisterFormBegin-->
                <input type="hidden" name="invite_user_id" value="0"/>
                <input type="hidden" id="url" name="url" value="{$url|htmlentities}"/>
                {:token()}

                <div class=" row">
<!--                    <label class="control-label col-xs-3">{:__('Username')}</label>-->
                    <div class="controls col-xs-12">
                        <input type="text" id="username" name="username" data-rule="required;username" class="form-control" placeholder="请输入用户名">
                    </div>
                </div>
                <div class=" row">
<!--                    <label class="control-label col-xs-3">{:__('Password')}</label>-->
                    <div class="controls col-xs-12" >
                        <input type="password" id="password" name="password" data-rule="required;password" class="form-control ma-t-20" placeholder="请输入密码">
                    </div>
                </div>
                <div class=" row">
                    <!--                    <label class="control-label col-xs-3">{:__('Password')}</label>-->
                    <div class="controls col-xs-12">
                        <input type="password" id="confirm_password" name="confirm_password" data-rule="required" class="form-control ma-t-20" placeholder="请输入确认密码">
                    </div>
                </div>
                <div class=" row">
<!--                    <label class="control-label col-xs-3">{:__('Mobile')}</label>-->
                    <div class="controls col-xs-12">
                        <input type="text" id="mobile" name="mobile" data-rule="required;mobile" class="form-control help-block" placeholder="请输入手机号">
                    </div>
                </div>

                <div class=" row">
                    <!--                    <label class="control-label col-xs-3">{:__('Captcha')}</label>-->
                    <div class="controls col-xs-12">
                        <div class="codeClass">
                            <div>
                                <input class="colmd7" type="text" name="code" placeholder="请输入验证码" class="form-control help-block" data-rule="required" />
                            </div>
                            <div>
                                <button id="sendCodeBtn2" type="button" class="colmd4" data-url="{:url('api/sms/send')}"
                                        data-type="mobile" data-event="[register]">发送验证码
                                </button>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="">
                    <button type="button" onclick="register()" class="btn-primaryClass">{:__('Sign up')}</button>
                </div>
                <div class="form-group-checkbox ma-t-20">
                    <input type="checkbox" class="basic-checkbox"  name="keeplogin" value="1">
                    <div style="margin-left: 10px;height: 45px">已阅读并同意用户协议和 隐私政策</div>
                </div>
                <!--@IndexRegisterFormEnd-->
            </form>
        </div>
    </div>
    </div>
</div>

<script src="__CDN__/static/js/jquery.min.js"></script>
<script src="__CDN__/static/layer/layer.js"></script>
<script>

    function register(){
        var currentURL = window.location.href;
        console.log(currentURL);
        $("#url").val(currentURL);
        var params = $("#register-form").serialize();
        $.post("{:url('index/user/register')}", params, function (res) {
            if (res.code == 1) {
                layer.msg(res.msg,{time: 2000,}, function () {
                    layer.closeAll();//疯狂模式，关闭所有层
                    location.href=res.url;
                })
            } else {
                layer.msg(res.msg);
                return;
            }
        })
    }

    $('#sendCodeBtn2').click(function () {


        $.post("{:url('api/sms/send')}",{mobile:$("#mobile").val(),event:'register'},function (res){
            if(res.code==1){
                layer.msg(res.msg);
                // 禁用按钮
                $("#sendCodeBtn2").prop('disabled', true);
                let countdown = 60; // 设置倒计时时间（秒）
                let timer = setInterval(function () {
                    // 更新按钮文本显示倒计时
                    $('#sendCodeBtn2').text(countdown + '秒后可重新发送');
                    countdown--;
                    if (countdown < 0) {
                        clearInterval(timer);
                        // 倒计时结束，恢复按钮文本和可点击状态
                        $('#sendCodeBtn2').text('发送验证码');
                        $('#sendCodeBtn2').prop('disabled', false);
                    }
                }, 1000);
            }else {
                layer.msg(res.msg);
                return;
            }
        })


    });
</script>
